﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace Sripirom.Pattern.UnitTest.Core.UnitTest
{
    public class ConfigDataConfigurationSection : ConfigurationSection
    {
        public ConfigDataConfigurationSection()     
        {
         
        }

        [ConfigurationProperty("Default", DefaultValue=null, IsRequired=true)]
        public string Default
        {
            get { return (string)base["Default"]; }
            set { base["Default"] = value; } 
        }


        public UnitTestCategoryConfigElement DefaultCatetory
        {
            get { return TestCategories[Default]; }
        }

        //Declare the Schema collection property.
        //Note: the "IsDefaultCollection = false" instructs 
        //.NET Framework to build a nested section of 
        //the kind <Schema> ...</Schema>.
        [ConfigurationProperty("UnitTestCategoryContainer", IsDefaultCollection = true)]
        [ConfigurationCollection(typeof(UnitTestCategoryElementCollection),
            AddItemName = "UnitTestCategory",
            ClearItemsName = "clear",
            RemoveItemName = "remove")]
        public UnitTestCategoryElementCollection TestCategories
        {
            get
            {
                UnitTestCategoryElementCollection testCategories = (UnitTestCategoryElementCollection)base["UnitTestCategoryContainer"];
                return testCategories;
            }
        }

    }

    public class UnitTestCategoryElementCollection : AbsConfigurationElementCollection<UnitTestCategoryConfigElement> {}
    public class UnitTestCategoryConfigElement : AbsConfigurationElement
    {

        #region Constructor
        public UnitTestCategoryConfigElement()
        {

        }
        #endregion

        /// <summary>
        /// FullyQualifiedName
        /// </summary>
        [ConfigurationProperty("Name", DefaultValue = null, IsRequired = false, IsKey = false)]
        public string Name
        {
            get { return (string)this["Name"]; }
            set { this["Name"] = value; }
        }

        //Declare the Schema collection property.
        //Note: the "IsDefaultCollection = false" instructs 
        //.NET Framework to build a nested section of 
        //the kind <Schema> ...</Schema>.
        [ConfigurationProperty("TestClasses", IsDefaultCollection = true)]
        [ConfigurationCollection(typeof(UnitTestClassConfigElementCollection),
            AddItemName = "UnitTestClass",
            ClearItemsName = "clear",
            RemoveItemName = "remove")]
        public UnitTestClassConfigElementCollection TestClasses
        {
            get
            {
                UnitTestClassConfigElementCollection testClasses = (UnitTestClassConfigElementCollection)base["TestClasses"];
                return testClasses;
            }                         
        }
    }

    public class UnitTestClassConfigElementCollection : AbsConfigurationElementCollection<UnitTestClassConfigElement>  {}
    public class UnitTestClassConfigElement : AbsConfigurationElement
    {
                                 
        #region Constructor
        public UnitTestClassConfigElement()
        {

        }
        #endregion

        /// <summary>
        /// FullyQualifiedName
        /// </summary>
        [ConfigurationProperty("Name", DefaultValue = null, IsRequired = false, IsKey = false)]
        public string Name
        {
            get { return (string)this["Name"]; }
            set { this["Name"] = value; }
        }

        /// <summary>
        /// FullyQualifiedName
        /// </summary>
        [ConfigurationProperty("Type", DefaultValue = null, IsRequired = false, IsKey = false)]
        public string Type
        {
            get { return (string)this["Type"]; }
            set { this["Type"] = value; }
        }

        //Declare the Schema collection property.
        //Note: the "IsDefaultCollection = false" instructs 
        //.NET Framework to build a nested section of 
        //the kind <Schema> ...</Schema>.
        [ConfigurationProperty("TestFunctions", IsDefaultCollection = true)]
        [ConfigurationCollection(typeof(UnitTestFunctionConfigElementCollection),
            AddItemName = "UnitTestFunction",
            ClearItemsName = "clear",
            RemoveItemName = "remove")]
        public UnitTestFunctionConfigElementCollection TestFunctions
        {
            get
            {
                UnitTestFunctionConfigElementCollection testFunctions = (UnitTestFunctionConfigElementCollection)base["TestFunctions"];
                return testFunctions;
            }
        }
    }

    public class UnitTestFunctionConfigElementCollection : AbsConfigurationElementCollection<UnitTestFunctionConfigElement> {}
    public class UnitTestFunctionConfigElement : AbsConfigurationElement
    {

        #region Constructor
        public UnitTestFunctionConfigElement()
        {

        }
        #endregion

        /// <summary>
        /// FullyQualifiedName
        /// </summary>
        [ConfigurationProperty("Name", DefaultValue = null, IsRequired = false, IsKey = false)]
        public string Name
        {
            get { return (string)this["Name"]; }
            set { this["Name"] = value; }
        }

        //Declare the Schema collection property.
        //Note: the "IsDefaultCollection = false" instructs 
        //.NET Framework to build a nested section of 
        //the kind <Schema> ...</Schema>.
        [ConfigurationProperty("TestCases", IsDefaultCollection = true)]
        [ConfigurationCollection(typeof(UnitTestCaseConfigElementCollection),
            AddItemName = "UnitTestCase",
            ClearItemsName = "clear",
            RemoveItemName = "remove")]
        public UnitTestCaseConfigElementCollection TestCases                   
        {                                                                  
            get
            {
                UnitTestCaseConfigElementCollection testCases = (UnitTestCaseConfigElementCollection)base["TestCases"];
                return testCases;
            }
        }
    }

    public class UnitTestCaseConfigElementCollection : AbsConfigurationElementCollection<UnitTestCaseConfigElement> { }
    public class UnitTestCaseConfigElement : AbsConfigurationElement
    {

        #region Constructor
        public UnitTestCaseConfigElement()
        {

        }
        #endregion

        /// <summary>
        /// FullyQualifiedName
        /// </summary>
        [ConfigurationProperty("Name", DefaultValue = null, IsRequired = false, IsKey = false)]
        public string Name
        {
            get { return (string)this["Name"]; }
            set { this["Name"] = value; }
        }


        /// <summary>
        /// FullyQualifiedName
        /// </summary>
        [ConfigurationProperty("Description", DefaultValue = null, IsRequired = false, IsKey = false)]
        public string Description
        {
            get { return (string)this["Description"]; }
            set { this["Description"] = value; }
        }

        /// <summary>
        /// FullyQualifiedName
        /// </summary>
        [ConfigurationProperty("IsError", DefaultValue = null, IsRequired = false, IsKey = false)]
        public Boolean IsError
        {
            get { return (Boolean)this["IsError"]; }
            set { this["IsError"] = value; }
        }

        //Declare the Schema collection property.
        //Note: the "IsDefaultCollection = false" instructs 
        //.NET Framework to build a nested section of 
        //the kind <Schema> ...</Schema>.
        [ConfigurationProperty("TestParameters", IsDefaultCollection = true)]
        [ConfigurationCollection(typeof(UnitTestParameterConfigElementCollection),
            AddItemName = "UnitTestParameter",
            ClearItemsName = "clear",
            RemoveItemName = "remove")]
        public UnitTestParameterConfigElementCollection TestParameters
        {
            get
            {
                UnitTestParameterConfigElementCollection testParameters = (UnitTestParameterConfigElementCollection)base["TestParameters"];
                return testParameters;
            }
        }

        /// <summary>
        /// FullyQualifiedName
        /// </summary>
        [ConfigurationProperty("ReturnType", DefaultValue = null, IsRequired = false, IsKey = false)]
        public String ReturnType
        {
            get { return (String)this["ReturnType"]; }
            set { this["ReturnType"] = value; }
        }

        /// <summary>
        /// FullyQualifiedName
        /// </summary>
        [ConfigurationProperty("ReturnValue", DefaultValue = null, IsRequired = false, IsKey = false)]
        public String ReturnValue
        {
            get { return (String)this["ReturnValue"]; }
            set { this["ReturnValue"] = value; }
        }

        /// <summary>
        /// FullyQualifiedName
        /// </summary>
        [ConfigurationProperty("Exception", DefaultValue = null, IsRequired = false, IsKey = false)]
        public String Exception
        {
            get { return (String)this["Exception"]; }
            set { this["Exception"] = value; }
        }

        /// <summary>
        /// FullyQualifiedName           
        /// </summary>
        [ConfigurationProperty("Ignore", DefaultValue = "", IsRequired = false, IsKey = false)]
        public string Ignore
        {
            get { return (string)this["Ignore"]; }
            set { this["Ignore"] = value; }
        }
    }

    public class UnitTestParameterConfigElementCollection : AbsConfigurationElementCollection<UnitTestParameterConfigElement> { }
    public class UnitTestParameterConfigElement : AbsConfigurationElement
    {

        #region Constructor
        public UnitTestParameterConfigElement()
        {

        }
        #endregion

        /// <summary>
        /// FullyQualifiedName
        /// </summary>
        [ConfigurationProperty("Name", DefaultValue = null, IsRequired = false, IsKey = false)]
        public string Name
        {
            get { return (string)this["Name"]; }
            set { this["Name"] = value; }
        }

        /// <summary>
        /// FullyQualifiedName
        /// </summary>
        [ConfigurationProperty("Type", DefaultValue = null, IsRequired = false, IsKey = false)]
        public string Type
        {
            get { return (string)this["Type"]; }
            set { this["Type"] = value; }
        }

        /// <summary>
        /// FullyQualifiedName           
        /// </summary>
        [ConfigurationProperty("Value", DefaultValue = null, IsRequired = false, IsKey = false)]
        public string Value
        {
            get { return (string)this["Value"]; }
            set { this["Value"] = value; }
        }
    }

  
}
